/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __GPK_FILE_H__
#define __GPK_FILE_H__

#include "NgPrerequisites.h"
#include "GPK.h"

namespace PQEngine
{
	/*Represent file in .gpk archive.
	We use this class to read data from .gpk file.
	*/
	class GPKFile
	{
	public:
		GPKFile();

		/*Construct a GPKFile using .gpk archive
		*/
		GPKFile(GPKArchive* archive,std::string fileName,int id,int fileSize);
		
		/*Must open before read.
		*/
		void open();
		
		/*Must close after read;
		*/
		void close();

		/*write local file at filePath to .gpk file
		@param size - in byte
		*/
		int read(char* buf,int size);

		inline std::string getFileName()
		{
			return _fileName;
		}

		inline bool eof()
		{
			return _eof;
		}

		inline bool ok()
		{
			return _ok;
		}

		inline int length()
		{
			return _fileSize;
		}

	private:
		GPKArchive* _owner;//the owner archive
		std::string _fileName;//
		int _readPtr;//read ptr in archive file
		int _fileId;//
		int _fileSize;//
		bool _eof;
		bool _ok;
		bool _isOpen;
	};

}
#endif


